﻿Imports System.Data.SqlClient
Public Class clsAsignacionServicios
    Private mintIdAsignacion As Integer
    Private mintIdServicio As Integer
    Private mintIdSubServicio As Integer
   
    Public Property IdAsignacion() As Integer
        Get
            Return mintIdAsignacion
        End Get
        Set(ByVal value As Integer)
            mintIdAsignacion = value
        End Set
    End Property
    Public Property IdServicio() As Integer
        Get
            Return mintIdServicio
        End Get
        Set(ByVal value As Integer)
            mintIdServicio = value
        End Set
    End Property
    Public Property IdSubservicio() As Integer
        Get
            Return mintIdSubServicio
        End Get
        Set(ByVal value As Integer)
            mintIdSubServicio = value
        End Set
    End Property
     Public Sub New()
        mintIdAsignacion = 0
        mintIdServicio = 0
        mintIdSubServicio = 0
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into AsignacionServicios (" & _
                            "IdServicio," & _
                            "IdSubservicio) " & _
                            "VALUES (" & _
                            "@IdServicio," & _
                            "@IdSubservicio) "


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdServicio", mintIdServicio)
        Command.Parameters.AddWithValue("IdSubservicio", mintIdSubServicio)
        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la asignacion ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
